package com.johnson.news.activity.base;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import io.reactivex.disposables.CompositeDisposable;

public abstract class BaseBindingNormalActivity<D extends ViewDataBinding> extends Activity {
    protected CompositeDisposable compositeDisposable;
    protected D dataBinding;
    protected BaseBindingNormalActivity activityInstance;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activityInstance = this;
        init();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if(compositeDisposable != null)
            compositeDisposable.clear();
    }

    void init() {
        dataBinding = DataBindingUtil.setContentView(this, getContentViewId());


        compositeDisposable = new CompositeDisposable();
    }

    protected void startActivity(Class<? extends Activity> activityClass, Bundle bundle) {
        Intent intent = new Intent(this, activityClass);
        if (bundle != null)
            intent.putExtras(bundle);
        startActivity(intent);
    }

    public abstract int getContentViewId();
}